<!-- 产品审核 -->


<template>
  <div>
    <el-table :data="dataList.slice((currentPage-1)*pagesize,currentPage*pagesize)" border style="width: 100%">
      <el-table-column prop="productId" label="产品编号" style="width:150px">
      </el-table-column>
      <el-table-column prop="productName" label="产品名称" style="width:150px">
      </el-table-column>
      <el-table-column prop="useType" label="用途类型" style="width:150px">
      </el-table-column>
      <el-table-column prop="firstKindName" label="I级分类" style="width:150px">
      </el-table-column>
      <el-table-column prop="secondKindName" label="II级分类" style="width:150px">
      </el-table-column>
      <el-table-column prop="thirdKindName" label="III级分类" style="width:150px">
      </el-table-column>
      <el-table-column label="复核" style="width:150px">
        <template slot-scope="scope">
          <!-- 	<el-button @click="handleClick(scope.row)" type="text" size="small">复核</el-button> -->
          <el-button type="primary" style="float:left;margin-bottom:20px" @click="details(scope.$index)">复核</el-button>
          <el-dialog title="复核" :visible.sync="dialogTableVisible">
            <el-form ref="from" :model="form" label-width="80px">
              <el-row>
                <el-col :span="8">
                  <el-form-item label="档案编号">
                    <el-input v-model="form.productId"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="产品名称">
                    <el-input v-model="form.productName"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="I级分类">
                    <el-input v-model="form.firstKindName"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="II级分类">
                    <el-input v-model="form.secondKindName"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="III级分类">
                    <el-input v-model="form.thirdKindName"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="24">
                  <el-form-item label="产品描述">
                    <el-input type="textarea" v-model="form.protDescribe"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="登记人">
                    <el-input v-model="form.registerName"></el-input>
                  </el-form-item>
                </el-col>

              </el-row>
              <el-row>
                <el-col :span="8">
                  <el-form-item label="市场价">
                    <el-input v-model="form.marketPrice"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :span="8">
                  <el-form-item label="成本价">
                    <el-input v-model="form.costPrice"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <!-- <el-row>
             <el-col :span="8">
                 <el-form-item label="单位">
                   <el-input v-model="form.put_monad"></el-input>
                 </el-form-item>
             </el-col>
           </el-row> -->
              <div class="aa">
                <el-form-item>
                  <el-button type="primary" @click="tongedr('复核通过')">复核通过</el-button>
                  <el-button type="primary" @click="tongedr('复核未通过')">不通过</el-button>
                  <el-button @click="diagooloff=false">返回</el-button>
                </el-form-item>
              </div>
            </el-form>
          </el-dialog>
        </template>
      </el-table-column>

    </el-table>
    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="this.currentPage"
      :page-sizes="[5, 10, 15]" :page-size="this.pagesize" layout="total, sizes, prev, pager, next, jumper" :total="total">
    </el-pagination>
  </div>
</template>

<script>
  import {
    getData,
    postData
  } from '../../api/axios.js'
  export default {
    created() {
      this.productFile();
    },
    computed: {
      total() { //返回信息的条数
        return this.dataList.length
      }
    },
    methods: {
      tongedr(flag) {
        let f = flag === '复核通过' ? 2 : 3
        postData('product/updateauris/' + this.form.productId + '/' + f)
          .then(response => {
            if (response.code == 200) {
              if(f === 2) {
                this.$message.success(flag)
              }else{
                this.$message.error(flag)
              }
              this.productFile()
              this.dialogTableVisible = false
            } else {
              this.$message.error('审核失败')
            }
          })
          .catch(err => {
            console.log(err)
          })
      },
      //当每页显示数据的条数发生变化时
      handleSizeChange: function(val) {
        this.pagesize = val
      },
      //当页码进行切换时
      handleCurrentChange: function(currentPage) {
        this.currentPage = currentPage;
      },
      productFile() {
        postData('product/fileproductFiles').then(response => {
          this.dataList = response.data;
          console.log(this.dataList)
        }).then(error => {
          console.log(error)
        })
      },
      //点击复核传入对应值
      details(index) {
        this.form = this.dataList[index];
        this.dialogTableVisible = true;
      }
    },
    data() {
      return {
        /* start----分页有关数据,利用计算属性，返回总记录数（total） */
        pagesize: 10,
        currentPage: 1,
        /* end----分页有关数据 */
        dataList: [{

        }],

        reexamine: false,
        dialogTableVisible: false,
        diagooloff: false,
        form: {
          productId: '',
          productName: '',
          firstKindName: '',
          secondKindName: '',
          thirdKindName: '',
          protDescribe: '',
          registerName: '',
          auditTime: '',
          costPrice: ''
        },

      }

    }
  }
</script>

<style>
  .aa {
    text-align: center;
  }

  .el-pagination {
    text-align: center;
  }
</style>
